package com.xcc.netty.socket.nio;

import java.nio.Buffer;
import java.nio.IntBuffer;

/**
 * @author frosty
 * @description  nio 中buff的作用
 * @date 2019-12-30 30:15:16
 */


public class BasicBuff {

    public static void main(String[] args) {
        //创建一个int类型的buffer  长度为5
        IntBuffer inbuffer=IntBuffer.allocate(5);
        //向buffer 里面存数据
       for(int i=0;i<inbuffer.capacity();i++){
           inbuffer.put(i*2);
       }
         //将buffer 转换   读写切换
       inbuffer.flip();
          while (inbuffer.hasRemaining()){
              System.out.println(inbuffer.get());
          }



    }



}
